<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>申报计划查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .cont{
        margin: 10px;
    }
    .item img {
        height: 40px;
    }
    .sear{
        background: #bfe8ff;
        height: 30px;
        text-align: center;
        line-height: 30px;
        font-size: 15px;
    }
    .btn {
        height: 30px;
        margin: 10px auto;
    }

    .btn button {
        float: right;
    }
    .share{
        width: calc(96% / 2);
        float: left;
    }
    .layui-inline{
        display: block;
    }
    .layui-form-label{
        width: 100px;
    }
   .layui-input-inline{
        width: 70% !important;
    }

    .layui-table-view i{
        width: 18px;
        height: 18px;
        margin-top: 5px;
    }
</style>
<body>
<div class="cont">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">申报计划查询</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="sear">
        项目查询
    </div>
    <div class="btn">
        <button type="button" class="layui-btn layui-btn-sm return" style="margin-left: 20px;display: none"><i
                class="layui-icon layui-icon-return"></i>返回
        </button>
        <button type="button" class="layui-btn layui-btn-sm find" style="background: #2b7fe0;"><i
                class="layui-icon layui-icon-search"></i>查询
        </button>
    </div>

    <div class="search">
        <div class="sear" style="text-align: left;">
            【查询条件】
        </div>
        <form class="layui-form" id="ajaxforms" action="" style="margin-top: 10px">
            <div class="layui-form-item">
                <div class="layui-inline share">
                    <label class="layui-form-label">项目名称:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="topicName" lay-verify="email" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline share">
                    <label class="layui-form-label">项目类别:</label>
                    <div class="layui-input-inline">
                        <select name="topicType" lay-verify="required" lay-search="">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline share">
                    <label class="layui-form-label">研究领域:</label>
                    <div class="layui-input-inline">
                        <select name="research" lay-verify="required" lay-search="">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline share">
                    <label class="layui-form-label">评分分数:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="reviewFraction" lay-verify="email" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline share">
                    <label class="layui-form-label">年度:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="year" lay-verify="email" autocomplete="off" class="layui-input" id="date">
                    </div>
                </div>
                <div class="layui-inline share">
                    <label class="layui-form-label">负责人:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="declare" user_id="" lay-verify="url" autocomplete="off" class="layui-input" disabled>
                    </div>
                    <a href="javascript:;" style="color:#1E9FFF; display: inline-block;margin-top: 10px;" class="add">添加</a>
                    <a href="javascript:;" style="color:red" class="clear">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline share">
                    <label class="layui-form-label">第二主持人:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="host" user_id="" lay-verify="url" autocomplete="off" class="layui-input" disabled>
                    </div>
                    <a href="javascript:;" style="color:#1E9FFF; display: inline-block;margin-top: 10px;" class="Execute">添加</a>
                    <a href="javascript:;" style="color:red" class="ecute">清空</a>
                </div>

               <%-- <div class="layui-inline share">
                    <label class="layui-form-label">负责人:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="rescueUser" user_id="" value="" lay-verify="url" autocomplete="off" class="layui-input" disabled>
                    </div>
                    <a href="javascript:;" style="color:#1E9FFF; display: inline-block;margin-top: 10px;" class="addExecute">添加</a>
                    <a href="javascript:;" style="color:red" class="clearExecute">清空</a>
                </div>--%>

            </div>
        </form>
    </div>
    <div class="tab" style="display: none;">
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>
</body>
</html>
<script>
    layui.use(['form', 'laydate', 'table'], function(){
        var form = layui.form,
            table = layui.table,
            laydate = layui.laydate;
        form.render()
        //日期
        laydate.render({
            elem: '#date'
        });
        $.ajax({
            url:'/rpmTopic/selectByparentNo',
            dataType: 'json',
            type: 'get',
            success:function (res) {
                var research = res.data.researchType
                var projectType = res.data.projectType
                var strs = ''
                var str = ''
                //研究领域
                for(var i=0;i<research.length;i++){
                    str += '<option value="' + research[i].dictNo + '">' +  research[i].dictName + '</option>'
                }
                //项目类别
                for(var i=0;i<projectType.length;i++){
                    strs += '<option value="' + projectType[i].dictNo + '">' +  projectType[i].dictName + '</option>'
                }
                $('select[name="research"]').append(str)
                $('select[name="topicType"]').append(strs);
                form.render('select');
            }
        })

      /*  //负责人点击添加的按钮
        $(".addExecute").on("click",function(){
            user_id = "rescueUser";
            $.popWindow("/common/selectUser?0");
        });

        $('.clearExecute').click(function () {
            $("#rescueUser").val("");
            $("#rescueUser").attr('username','');
            $("#rescueUser").attr('dataid','');
            $("#rescueUser").attr('user_id','');
            $("#rescueUser").attr('userprivname','');
        });*/
        //申报人点击添加的按钮
        $(".add").on("click",function(){
            user_id = "declare";
            $.popWindow("/common/selectUser?0");
        });

        $('.clear').click(function () {
            $("#declare").val("");
            $("#declare").attr('username','');
            $("#declare").attr('dataid','');
            $("#declare").attr('user_id','');
            $("#declare").attr('userprivname','');
        });
        //第二主持人点击添加的按钮
        $(".Execute").on("click",function(){
            user_id = "host";
            // user_id  = $("#host").attr("user_id")
            $.popWindow("/common/selectUser?0");
        });

        $('.ecute').click(function () {
            $("#host").val("");
            $("#host").attr('username','');
            $("#host").attr('dataid','');
            $("#host").attr('user_id','');
            $("#host").attr('userprivname','');
        });

       var tableInt = table.render({
            elem: '#test'
            , url: '/rpmTopic/selectCondition'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code":0, //解析接口状态
                    "data": res.object, //解析数据列表，
                    "count": res.totleNum, //解析数据长度
                };
            }
            , defaultToolbar: ['']
            , title: '用户数据表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'topicName', title: '项目名称'}
                , {field: 'unitName', title: '负责人'}
                , {field: 'research', title: '研究领域'}
                , {field: 'topicType', title: '项目类别'}
                , {field: 'year', title: '年度'}
                , {field: 'headUserName2', title: '第二主持人'}
            ]]
            , page: true
        });
        $('.find').click(function () {
           $('.search').hide()
            $('.tab').show()
            $('.return').show()
            $('.find').hide()
            if($('input[name="topicName"]').val() !='' || $('input[name="topicType"]').val() !='' ||
                $('input[name="research"]').val() !=''   || $('input[name="reviewFraction"]').val() !='' ||
                $('input[name="year"]').val() !='' || $('#declare').val() !=''||
                $('#host').val() !=''){
                tableInt.reload({
                    url:'/rpmTopic/selectCondition',
                    where:{
                        userId:$('#declare').attr('user_id').split(',')[0],
                        headUserId2:$('#host').attr('user_id').split(',')[0],
                       // headUserId:$('#rescueUser').attr('user_id').split(',')[0],
                        topicName:$('input[name="topicName"]').val(),
                        research:$('select[name="research"]').val(),
                        topicType:$('select[name="topicType"]').val(),
                        year:$('input[name="year"]').val(),
                        reviewFraction:$('input[name="reviewFraction"]').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });

            }else{
                tableInt.reload()
            }
        })
        $('.return').click(function () {
            $('.search').show()
            $('.tab').hide()
            $('.return').hide()
            $('.find').show()
        })

    })
</script>
